<?php

/***********************************************/
/*CONTENIDO*/
/***********************************************/
echo" <div class=\"pag_content\">
 	<div class=\"pag_content_title\">
		<div class=\"pag_title_cap\">Cap&iacute;tulo 4: </div>
		<div class=\"pag_title_cont\">Restauraci&oacute;n y recuperaci&oacute;n</div>
    </div>
    <div class=\"pag_content_body\">         
	<div class=\"contenido_principal\">	
		<br />";
		
/***********************************************/
/*TITULO PARTE*/
/***********************************************/

echo"	<div class=\"parrafo_titulo\">
		Tipos de recuperaci&oacute;n
	</div>";		

	
/***********************************************/
/*CONTENIDO*/
/***********************************************/

echo"
<div class=\"parrafo\" align=\"justify\">
Existen varios tipos de recovery:
<div class=\"parrafo_lista_sub\">
a) Server-Recovery<br />
b) User-Recovery<br />
</div>
</div>

<h3>1. Server-Recovery</h3>
<div class=\"parrafo\" align=\"justify\">
Este metodo consiste en utilizar el RMAN. Oracle recomienda utilizar este metodo tanto para la restauracion como para la recuperacion.
</div>
<div class=\"parrafo\" align=\"justify\">
Vamos a provocar la perdida de un datafile para mostrar un ejemplo de como se haria este tipo de recuperacion.
</div>
<div class=\"parrafo\" align=\"justify\">
1. Generamos el error
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>>  mv example01.dbf example01_bk.dbf

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
2. Obtenemos el fallo en oracle
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&GT; shutdown immediate
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/example01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
3. Forzamos la bajada de la base de datos
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&gt; shutdown abort

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
4. Para aplicar la recuperacion la base de datos debe de estar montada
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&gt; startup mount;

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
5. Aplicamos la recuperacion
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>RMAN&GT; run
2> {
3> allocate channel c1 type disk;
4> restore database;
5> recover database;
6> alter database open;
7> }

allocated channel: c1
channel c1: sid=155 devtype=DISK

Starting restore at 11-MAR-11

channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oracle/product/10.2.0/oradata/orcl2/example01.dbf
channel c1: 
reading from backup piece o1_mf_nnndf_TAG20110311T153752_6qndy158_.bkp
channel c1: restored backup piece 1
piece handle=o1_mf_nnndf_TAG20110311T153752_6qndy158_.bkp tag=TAG20110311T153752
channel c1: restore complete, elapsed time: 00:01:37
Finished restore at 11-MAR-11

Starting recover at 11-MAR-11

starting media recovery

archive log thread 1 sequence 13 is already on disk as file 
/flash_recovery_area/ORCL2/archivelog/2011_03_11/o1_mf_1_13_6qnfypbk_.arc
archive log thread 1 sequence 41 is already on disk as file 
/flash_recovery_area/ORCL2/archivelog/2011_03_11/o1_mf_1_14_6qnfytq7_.arc
archive log thread 1 sequence 15 is already on disk as file 
/flash_recovery_area/ORCL2/archivelog/2011_03_11/o1_mf_1_15_6qnfyyqo_.arc
archive log filename=/flash_recovery_area/ORCL2/archivelog/2011_03_11/o1_mf_1_13_6qnfypbk_.arc 
thread=1 sequence=13
media recovery complete, elapsed time: 00:00:02
Finished recover at 11-MAR-11

database opened
released channel: c1


</p></pre></blockquote>

<h3>2. User-Recovery</h3>
<div class=\"parrafo\" align=\"justify\">
En este metodo es el usuario el que gestiona manualmete la recuperacion de la base de datos.
</div>
<div class=\"parrafo\" align=\"justify\">
Simulemos la perdida de un datafile para mostrar este ejemplo:
</div>
<div class=\"parrafo\" align=\"justify\">
1. Realizamos la copia del datafile del que queremos simular el fallo.
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>> cp users01.dbf users01.dbf_old

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
2. Insertamos unos cuantos registros en alguna tabla del tablespace users y lanzamos el commit.
</div>
<div class=\"parrafo\" align=\"justify\">
3. Provocamos el fallo.
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>>mv users01.dbf user01_bk.dbf

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
4. Al intentar acceder a la tabla de ese data file nos da un error de acceso.
</div>
<div class=\"parrafo\" align=\"justify\">
5. Forzamos el bajado de la base de datos:
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&gt; shutdown abort;

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
6. Dejamos la base de datos montada:
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&gt; startup mount;

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
7. Hacemos la recuperacion de la base de datos:
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&GT; recover database;
ORA-00279: change 550561 generated at 03/11/2011 16:23:27 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/oracle/product/10.2.0/db_2/flash_recovery_area/ORCL2/archivelog/
2011_03_11/o1_mf_1_17_%u_.arc
ORA-00280: change 550561 for thread 1 is in sequence #17


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
Log applied.
Media recovery complete.

</p></pre></blockquote>
<div class=\"parrafo\" align=\"justify\">
8. Abrimos la base de datos:
</div>
<blockquote style=\"COLOR: #2e5348; FONT-SIZE: 12px; FONT-WEIGHT: bold FONT:Arial, Helvetica, sans-serif\">
<pre><p>SQL&gt; ALTER DATABASE OPEN;

</p></pre></blockquote>

";
	
echo"
	</div> 		 
    </div>
    <div class=\"pag_content_footer\">
    </div>
    <div class=\"pag_content_nav\">		
		<div class=\"pag_contenido_left\">
			<a  class=\"cap_next\" href=\"ocp_main.php?cap=4&part=0\">	&lt; Anterior </a>
		 </div>
		<div class=\"pag_contenido_right\" align=\"right\">	
			<a  class=\"cap_next\" href=\"ocp_main.php?cap=4&part=2\">	Siguiente &gt;</a>
		 </div>
	</div>      
</div>
";


?>